﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://www.codeplex.com/MSSqlSchemaDoc">

  <xsl:import href="ProcedureParameter.xsl" />
  <xsl:param name="DocumentationFile"/>

  <xsl:template match="/s:StoredProcedure">
    <html>
      <head>
        <title>
          Stored Procedure: <xsl:value-of select="@Schema"/>.<xsl:value-of select="@Name"/>
        </title>
        <link rel="stylesheet" type="text/css" href="../main.css"/>
      </head>
      <body>
        <table width="100%">
          <tr>
            <td width="50%" class="descriptionHeader right">Stored Procedure: </td>
            <td class="objectName">
              <xsl:value-of select="@Schema"/>.<xsl:value-of select="@Name"/>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          <tr class="center">
            <td colspan="2" class="documentationHeader">
              Description:
            </td>
          </tr>
          <tr>
            <td colspan="2" class="documentation center">
              <pre>
                <xsl:value-of select="document($DocumentationFile)/s:StoredProcedureDocumentation/s:Documentation"/>
              </pre>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          <tr>
            <td colspan="2" class="documentationHeader center">
              Parameters:
            </td>
          </tr>

          <tr>
            <td colspan="2">
              <table width="100%">
                <tr class="tableHeader center">
                  <td></td>
                  <td>Data Type</td>
                  <td>IsOutputParameter</td>
                  <td>IsCursorReference</td>
                  <td>HasDefaultValue</td>
                  <td>IsCompleteXmlDocument</td>
                  <td>XmlCollectionId</td>
                </tr>

                <xsl:for-each select="s:Parameters/s:ProcedureParameter">
                  <xsl:apply-templates select="."/>
                </xsl:for-each>
              </table>
            </td>
          </tr>

          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">IsAutoExecuted</td>
            <td>
              <xsl:value-of select="s:IsAutoExecuted"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">IsExecutionReplicated</td>
            <td>
              <xsl:value-of select="s:IsExecutionReplicated"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">IsReplicationSerializableOnly</td>
            <td>
              <xsl:value-of select="s:IsReplicationSerializableOnly"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">SkipsReplicationConstraints</td>
            <td>
              <xsl:value-of select="s:SkipsReplicationConstraints"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">UsesAnsiNulls</td>
            <td>
              <xsl:value-of select="s:UsesAnsiNulls"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">UsesQuotedIdentifier</td>
            <td>
              <xsl:value-of select="s:UsesQuotedIdentifier"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">IsSchemaBound</td>
            <td>
              <xsl:value-of select="s:IsSchemaBound"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">UsesDatabaseCollation</td>
            <td>
              <xsl:value-of select="s:UsesDatabaseCollation"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">IsRecompiled</td>
            <td>
              <xsl:value-of select="s:IsRecompiled"/>
            </td>
          </tr>
          <tr>
            <td class="descriptionHeaderMedium right">ExecuteAsPrincipalId</td>
            <td>
              <xsl:value-of select="s:ExecuteAsPrincipalId"/>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          <tr>
            <td colspan="2" class="descriptionHeader center">
              Definition:
            </td>
          </tr>
          <tr>
            <td colspan="2" class="procedureDefinition">
              <pre>
                <xsl:value-of select="s:Definition"/>
              </pre>
            </td>
          </tr>
        </table>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>